<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends User_Controller {

	public function __construct()
    {
        parent::__construct();
        // Your own constructor code
    }

	function index(){
		$uid = $this->user_data['id'];
		$course[1] = get_field_by_where("o2o_student_item_terms", "count(id) AS count", "uid='{$uid}' AND data_type = 1");

		$course[2] = get_field_by_where("o2o_student_item_terms", "count(id) AS count", "uid='{$uid}' AND data_type = 2");

		$course[3] = get_field_by_where("o2o_student_item_terms", "count(id) AS count", "uid='{$uid}' AND data_type = 3");

		$course[4] = get_field_by_where("o2o_student_item_terms", "count(id) AS count", "uid='{$uid}' AND data_type = 4");

		$course[5] = get_field_by_where("o2o_student_item_terms", "count(id) AS count", "uid='{$uid}' AND data_type = 5");
		$this->smarty->assign("course", $course);

		$this->load->model('User_center_model');
		$classes = $this->User_center_model->get_class_by_uid(0, 1, array("uid" => $uid));
		$this->smarty->assign("classes_count", $classes['count']);

    	$sub_user[1] = $this->User_model->get_user_by_parent1($uid, 0, 1);
    	$sub_user[2] = $this->User_model->get_user_by_parent2($uid, 0, 1);
    	$sub_user[3] = $this->User_model->get_user_by_parent3($uid, 0, 1);
    	$this->smarty->assign("sub_user", $sub_user);

		$this->load->model('User_model');
		$user_account = $this->User_model->get_user_account_by_id($this->user_data['id']);
		$this->smarty->assign("user_account",$user_account);

		$this->smarty->assign("menu", "home");
		$this->smarty->display("user/my_index.html");
	}


}
